package com.example.teesystem.entityDto;

import com.example.teesystem.common.cache.UserCache;
import com.example.teesystem.common.utils.TimeUtil;
import com.example.teesystem.entity.ExamEvaluation;
import com.example.teesystem.entity.ExamPaper;
import com.example.teesystem.entity.User;
import lombok.Data;

/**
 * @author : NieYaShi
 * @version : v1.0
 * @createTime : 2022/4/21 10:55
 */
@Data
public class MarkedPaperList {
    private Integer studentId;
    private String studentName;
    private String academy;
    private Integer paperId;
    private String paperName;
    private String examTime;
    private Integer score;
    private String url;

    public MarkedPaperList(Integer studentId, ExamPaper examPaper, ExamEvaluation examEvaluation){
        this.studentId = studentId;
        User def = new User();
        def.setMyName("用户未找到");
        this.studentName = UserCache.userMap.getOrDefault(studentId, def).getUsername();
        this.academy = UserCache.userMap.getOrDefault(studentId, def).getAcademy();
        this.paperId = examPaper.getId();
        this.paperName = examPaper.getName();
        this.examTime = TimeUtil.dateTimeToString(examPaper.getStartTime());
        this.url = examPaper.getUrl();
        this.score = examEvaluation.getScore();
    }
}
